package com.anyisn.anyflickr.shell.model
{
	import com.adobe.webapis.flickr.events.FlickrResultEvent;
	
	import com.anyisn.anyflickr.shell.ShellFacade;
	import com.anyisn.flickr.as3.patterns.proxy.FlickrServiceProxy;
	
	public class TestProxy extends FlickrServiceProxy
	{
		public static const NAME:String = 'TestProxy';
		
		public function TestProxy(data:Object=null)
		{
			super(NAME, data);
		}
		
		public function testOnline():void {
			service.addEventListener(FlickrResultEvent.TEST_ECHO, onTestOnline);
			service.test.echo();
		}
		
		private function onTestOnline(event:FlickrResultEvent):void {
			service.removeEventListener(FlickrResultEvent.TEST_ECHO, onTestOnline);
			if(event.success) {
				sendNotification(ShellFacade.ONLINE);
			} else {
				onFlickrError(event);
				sendNotification(ShellFacade.OFFLINE);
			}
		}
	}
}